/*
 * rayqueue.h
 *
 *  Created on: Feb 22, 2010
 *      Author: pitidecaner
 *
 *      define queue to store rays in ther way get solved.
 *      it does not realy matter if we implemet it FIFO or LIFO
 *         his time LIFO
 *
 *      has functions to store them, and to recover them
 *
 */

#ifndef RAYQUEUE_H_
#define RAYQUEUE_H_
#include "types.h"

/**
 * initialize ray queue
 * input
 *       copies: number of threads to make their own memory space
 * output: rayqueue opaque pointer if ok
 *         NULL if any error happens, see system error
 */
inline rayqueue * rt_rq_initialize (int);

/**
 * delete ray queue, frees resources alocated
 * input q: rayqueue opaque pointer
 *          num of threads that where alocated
 * output: 0 if ok
 *         != if any error happens, see system error
 */
inline void rt_rq_delete (rayqueue *q,int);

/**
 * pops a ray from the queue, if not returns NULL
 * input q: rayqueue opaque pointer
 * 		 c: thread poll where get the ray from
 * output: Ray in queue if exists
 *         NULL if empty
 */
inline ray *rt_rq_get_ray (rayqueue *q,int);

/**
 * push a ray in the queue
 * input q: rayqueue opaque pointer
 *       r: ray to be enqueued
 *       c: thread poll where put the ray
 * output: 0 if ok
 *         != if error
 */
inline void rt_rq_add_ray(rayqueue *q, ray *r,int);

/**
 * get size of que queue
 */
inline long rt_rq_get_size(rayqueue *q, int);


/*********************** RAY MEMORY MANAGEMENT **************************/

inline ray * rt_rq_newray(rayqueue *q, int);
inline void  rt_rq_eraseray(rayqueue *q,ray *, int);

#endif /* RAYQUEUE_H_ */
